﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;

public partial class Agency_SuperviseJFB : System.Web.UI.Page
{
    int SJFBprojectid;
    int SJFBId;
    protected void Page_Load(object sender, EventArgs e)
    {
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {
            SJFBprojectid = SysFun.ToInt(SysFun.IsSQL(Request.QueryString["projectid"]));
            SJFBId = SysFun.ToInt(SysFun.IsSQL(Request.QueryString["id"]));
            string _strPassWord = SysFun.IsSQL(SysFun.ToTrim(Request.QueryString["PassWord"]));            
            if (!HZ.MBSM.BLL.Login.CheckPerson("ws001", _strPassWord, "4"))
            {
                Response.Write("<script>window.alert('对不起,密码不对！');</script>");
                Response.Write("<script>window.location=\"systemlogo.aspx?Projectid=" + SJFBprojectid.ToString() + "\"</script>");
            }

        }
        else
        {
            Response.End();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
       
        string sql;
       
        if (TextBox1.Text == "")
        {
            Response.Write("<script>window.alert('请填写密码')</script>");
        }
        else
        {
            string _strPassWord = TextBox1.Text.ToString().Trim();
            int count = 0;
            Db db = new Db();
            System.Data.IDataReader dr;
            //sql = "select count (*) as cun from account,project where projectid=" + SJFBprojectid + " and account.accountid=project.accountid and  pwd_bid='" + TextBox1.Text.ToString().Trim() + "'";
            //sql = "Select Count(*) as cun From Account,SuperVise Where Account.AccountId=SuperVise.AccountId And SuperviseName='省纠风办' And SuperVise.Accountid='2936' And pwd_bid='" + TextBox1.Text.ToString().Trim() + "'";
            sql = "select count(*) as cun from account where AccountName='jf001' And pwd_bid='" + _strPassWord + "'  ";
            dr = db.DataReader(sql);
            while (dr.Read())
            {
                count = SysFun.ToInt(dr["cun"].ToString());
            }
            db.Close();
            dr.Close();
            dr.Dispose();
            if (count > 0)
            {
                _strPassWord = SysFun.PasswordEncrypt(_strPassWord);
                Response.Write("<script>window.alert('解密成功');</script>");
                Button1.Dispose();
                if (SJFBId == 1)
                {
                    Response.Write("<script>window.location=\"PriceDEC.aspx?projectid=" + SJFBprojectid.ToString() + "&PassWord=" + _strPassWord + "\"</script>");
                }
                else 
                {
                    Response.Write("<script>window.location=\"CompetePriceDEC.aspx?projectid=" + SJFBprojectid.ToString() + "&PassWord=" + _strPassWord + "\"</script>");
                }
            }
            else
            {
                Response.Write("<script>window.alert('密码错误！请重新输入');</script>");
                TextBox1.Text = "";

            }
           
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "";
    }
}
